package tcln.gxtx.client.widget.grid.menu;

import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.google.gwt.user.client.ui.AbstractImagePrototype;

/**
 * Extension to {@link MenuItem} to provide a unique ID for each 'functional' menus.
 * 
 * @param <K> Unique ID object type for this menu.
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
public class ExtendedMenuItem<K> extends MenuItem {

    /**
     * Unique identifier of this menu item in the whole menu bar which contains this item.
     */
    private K menuId;

    /**
     * 
     */
    public ExtendedMenuItem() {
        super();
    }

    /**
     * @param text
     * @param icon
     * @param listener
     */
    public ExtendedMenuItem(String text, AbstractImagePrototype icon, SelectionListener<? extends MenuEvent> listener) {
        super(text, icon, listener);
    }

    /**
     * @param text
     * @param icon
     */
    public ExtendedMenuItem(String text, AbstractImagePrototype icon) {
        super(text, icon);
    }

    /**
     * @param text
     * @param listener
     */
    public ExtendedMenuItem(String text, SelectionListener<? extends MenuEvent> listener) {
        super(text, listener);
    }

    /**
     * @param text
     */
    public ExtendedMenuItem(String text) {
        super(text);
    }

    /**
     * Returns current value of {@link #menuId}.
     * 
     * @return the {@link #menuId}.
     */
    public K getMenuId() {
        return menuId;
    }

    /**
     * Sets new value for {@link #menuId}.
     * 
     * @param menuId
     *            the new menuId to set
     * @return this instance.
     */
    public ExtendedMenuItem<K> menuId(K menuId) {
        this.menuId = menuId;
        return this;
    }
}
